<?php

include_once 'config.php';

class Registration_class
{
//DECLARATION OF VARIABLES.
	
	var $Message='';	
	
//CLASS CONSTRUCTORS.

	function __construct()//DEFAULT CONSTRUCTOR
	{
	}
	
	function __destruct()//DEFAULT CONSTRUCTOR
	{
	}
	
//**********************************	

//CLASS FUNCTIONS.
	
	function Register_Buyer()
	{
		$act_conn=OpenConnection();	
		$idflag=true;
		$qry="Select * from buyers where Bid='$Bid'";
		$rs=mysql_query($qry, $act_conn) or die(mysql_error());
		$row=mysql_fetch_array($rs);
				if($row["Bid"]!="")
				{
				$this->Message='<h4><font color="red">Error: This User Id is not available!!</font></h4>';
				$idflag=false;
				}
		
				if($idflag!=false && $Bid!="Not Available")
				{
				$Bid=mysql_escape_string($_POST["Bid"]);
				$fname=mysql_escape_string($_POST["fname"]);
				$lname=mysql_escape_string($_POST["lname"]);
				$Bpass=mysql_escape_string($_POST["Bpass"]);		
				$BillStreet=mysql_escape_string($_POST["BillStreet"]);
				$BillCity=mysql_escape_string($_POST["BillCity"]);
				$BillState=mysql_escape_string($_POST["BillState"]);
				$BillCountry=mysql_escape_string($_POST["BillCountry"]);
				$BillZip=mysql_escape_string($_POST["BillZip"]);
				$ShipStreet=mysql_escape_string($_POST["ShipStreet"]);
				$ShipCity=mysql_escape_string($_POST["ShipCity"]);
				$ShipState=mysql_escape_string($_POST["ShipState"]);
				$ShipCountry=mysql_escape_string($_POST["ShipCountry"]);
				$ShipZip=mysql_escape_string($_POST["ShipZip"]);				
				$phone=mysql_escape_string($_POST["phone"]);
				$email=mysql_escape_string($_POST["email"]);
				$paypalid=mysql_escape_string($_POST["paypalid"]);
				
				$qry="Insert Into buyers(site_id, fname, lname, Bid, Bpass, address, BillStreet, BillCity, BillState, BillCountry, BillZip, ShipStreet, ShipCity, ShipState, ShipCountry, ShipZip, paypal_id, phone, email) values($_SESSION['SITE_ID'], '$fname', '$lname', '$Bid', '$Bpass', '$BillStreet', '$BillCity', '$BillState', '$BillCountry', '$BillZip', '$ShipStreet', '$ShipCity', '$ShipState', '$ShipCountry', '$ShipZip', '$paypalid', '$phone', '$email')";
				mysql_query($qry) or die(mysql_error());
				$this->Message='<h4><font color="red">Registration Succeed!!</font></h4>';
				}
				else
				{
				$this->Message='<h4><font color="red">Error: Necessary fields can\'t be left empty.!!</font></h4>';
				}
				
				CloseConnection($act_conn);
	}
	
}//CLASS ENDS HERE.		
		
?>